package com.learn;

import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.ScheduledReporter;
import metrics_influxdb.InfluxdbReporter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.util.concurrent.TimeUnit;

@SpringBootApplication
public class MertricsApplication {



	public static void main(String[] args) {
		ApplicationContext ctx = SpringApplication.run(MertricsApplication.class, args);

		// 启动Reporter
		ConsoleReporter reporter = ctx.getBean(ConsoleReporter.class);

		ScheduledReporter influxdbReporter = (ScheduledReporter) ctx.getBean("influxdbReporter");
		influxdbReporter.start(1, TimeUnit.SECONDS);
		reporter.start(1, TimeUnit.SECONDS);

	}
}
